package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.annos.EncapsulateMap;
import com.tbit.uqbike.object.pojo.BlackListLog;
import com.tbit.uqbike.object.pojo.UserBlackList;
import com.tbit.uqbike.object.value.LoginInfo;
import com.tbit.uqbike.service.business.BlackListLogService;
import com.tbit.uqbike.webmanager.dao.log.BlackListLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

/**
 * @author jing
 * @date 2020/10/2811:33
 * @Description:
 */
@Service("blackListLogService")
public class BlackListLogServiceImpl implements BlackListLogService {
    @Autowired
    private BlackListLogDao blackListLogDao;

    @Override
    public void insert(LoginInfo loginInfo, UserBlackList userBlackList) {
        BlackListLog blackListLog = new BlackListLog();
        blackListLog.setAccountid(userBlackList.getAccountId());
        blackListLog.setUserid(userBlackList.getUserId());
        blackListLog.setUserphone(userBlackList.getPhone());
        blackListLog.setIdNo(userBlackList.getIdNo());
        blackListLog.setAddaccountuserid(loginInfo.getAccountUserId());
        blackListLog.setAddaccountuserphone(loginInfo.getPhone());
        blackListLog.setAddtime(userBlackList.getAddTime());
        blackListLog.setReason(userBlackList.getRemark());
        blackListLog.setRemark("过期时间是：" + new SimpleDateFormat("yyyy-MM-dd HH:ss:mm").format(userBlackList.getExpireTime()));
        blackListLog.setPhotosUrl(userBlackList.getPhotosUrl());
        blackListLogDao.insertSelective(blackListLog);
    }

    @Override
    @EncapsulateMap(name = "blackListLog")
    public List<BlackListLog> getByPhone(Map<String, Object> params, Integer brandId, String phone, String idNo, String operatorNumber, Integer rowCount, Integer pageNO) {
        return blackListLogDao.selectByPhone(params);
    }

    @Override
    @EncapsulateMap(name = "Count")
    public Integer getCountByPhone(Map<String, Object> params, Integer brandId, String phone, String idNo, String operatorNumber) {
        return blackListLogDao.selectCountByPhone(params);
    }
}
